//
//  ZXJSettingNewPWViewController.m
//  academic_records
//
//  Created by zhang bozhao on 2020/8/5.
//  Copyright © 2020 zhang bozhao. All rights reserved.
//

#import "ZXJSettingNewPWViewController.h"
#import "LoginRequest.h"
#import "ZXJPasswordLoginViewController.h"

@interface ZXJSettingNewPWViewController ()
@property (weak, nonatomic) IBOutlet UIView *FirstPasswordView;
@property (weak, nonatomic) IBOutlet UIView *TwicePasswordView;
@property (weak, nonatomic) IBOutlet UIButton *submitBtn;
@property (weak, nonatomic) IBOutlet UITextField *firstTF;
@property (weak, nonatomic) IBOutlet UITextField *secondTF;
@end

@implementation ZXJSettingNewPWViewController
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController.navigationBar setHidden:YES];
    self.tabBarController.hidesBottomBarWhenPushed = YES;
}
- (IBAction)backAction:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.FirstPasswordView.layer.cornerRadius = 22.0f;
    self.TwicePasswordView.layer.cornerRadius = 22.0f;
    self.firstTF.secureTextEntry = YES;
    self.secondTF.secureTextEntry = YES;
}
- (IBAction)changePasswordSecurityAction:(id)sender {
    UIButton *btn = sender;
    btn.selected = !btn.selected;
    if (btn.selected == YES) {
        [btn setImage:[UIImage imageNamed:@"yanshi"] forState:(UIControlStateNormal)];
        if (btn.tag == 100) {
            self.firstTF.secureTextEntry = NO;
        }else{
            self.secondTF.secureTextEntry = NO;
        }
    }else{
        [btn setImage:[UIImage imageNamed:@"yingcang"] forState:(UIControlStateNormal)];
        if (btn.tag == 100) {
           self.firstTF.secureTextEntry = YES;
       }else{
           self.secondTF.secureTextEntry = YES;
       }
    }
}
- (IBAction)submitAction:(id)sender {
    MJWeakSelf
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    [params setObject:[[NSUserDefaults standardUserDefaults]objectForKey:@"PHONENUM"] forKey:@"phone"];
    [params setObject:self.verityCode forKey:@"code"];
    [params setObject:[NSString stringWithFormat:@"%@",self.firstTF.text] forKey:@"pwd"];
    [params setObject:[NSString stringWithFormat:@"%@",self.secondTF.text] forKey:@"confirmPwd"];
    [LoginRequest get_userpwd:params :^(id  _Nullable data, ResultCode resultCode, NSError * _Nullable Error) {
        if (resultCode == SucceedCode) {
            ZXJPasswordLoginViewController *loginVC = [[ZXJPasswordLoginViewController alloc]init];
            [weakSelf.navigationController pushViewController:loginVC animated:YES];
        }
    }];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
